<?php
require("dbFunctions.php");

//ADICIONA SISTEMA
if(	isset($_POST['module']) && $_POST['module'] == 'system' && 
	isset($_POST['action']) && $_POST['action'] == 'add'){
	$name 			= $_POST['name'];
	$description 	= $_POST['description'];
	addSystem($name,$description) 
		or die("Erro ao adicionar Sistema");
}

//ADICIONA SUPLEMENTO
if(	isset($_POST['module']) && $_POST['module'] == 'supplement' && 
	isset($_POST['action']) && $_POST['action'] == 'add'){
	$name 			= $_POST['name'];
	$description 	= $_POST['description'];
	$idSystem 		= $_POST['idSystem'];
	addSupplement($name,$description, $idSystem) 
		or die("Erro ao adicionar Suplemento.");
}

//ADICIONA CR&Ocirc;NICA
if(	isset($_POST['module']) && $_POST['module'] == 'chronicle' && 
	isset($_POST['action']) && $_POST['action'] == 'add'){
	$name 			= $_POST['name'];
	$description 	= $_POST['description'];
	$idStoryteller 	= $_POST['idStoryteller'];
	$idSupplement 	= $_POST['idSupplement'];
	$dtIni 			= isset($_REQUEST["dtIni"]) ? $_REQUEST["dtIni"] : "";
	$dtEnd 			= isset($_REQUEST["dtEnd"]) ? $_REQUEST["dtEnd"] : "";
	addChronicle($name,$description, $idStoryteller, $idSupplement, $dtIni, $dtEnd) 
		or die("Erro ao adicionar cr&ocirc;nica.");
}

//EDITA PERFIL
if(	isset($_POST['module']) && $_POST['module'] == 'perfil' && 
	isset($_POST['action']) && $_POST['action'] == 'edit'){
	$name 			= $_POST['name'];
	$avatar 		= $_POST['avatar'];
	$email 			= $_POST['email'];
	$id				= $_POST['id'];
	editPerfil($name,$avatar, $email, $id) 
		or die("Erro ao Editar Perfil");
}
?>